package com.lvwenguo.controller;

import com.lvwenguo.service.ServiceInter;
import com.lvwenguo.service.serviceImple.ServiceImple;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

//逻辑删除商品
@WebServlet(urlPatterns = "/DeleteProductServlet")
public class DeleteProductServlet extends HttpServlet {
    ServiceInter serviceImpol =new ServiceImple();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        String bar_code=req.getParameter("bar_code");
        int i= serviceImpol.deleteProduct(bar_code);
        //表示逻辑删除成功
        if(i==1 || i>0){
            resp.sendRedirect("http://localhost:8080/supermarket/IndexProductListServlet/product/product_list");
        }
        else{
            //表示删除不成功

        }

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req,resp);
    }
}
